package service.impl;

import entity.SysUser;
import mapper.SysUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import service.SysUserService;

import java.util.Collections;
import java.util.List;

@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService{

    @Autowired
    private SysUserMapper sysUserMapper;
    @Override
    public List<SysUser> findList(SysUser sysUser) {
        return sysUserMapper.getSysUserList(sysUser);
    }

    @Override
    public int savaBatch(List<SysUser> sysUserList) {
        int rows = 0;
        for(int i = 0;i<sysUserList.size();i++){
            SysUser sysUser = sysUserList.get(i);
            if(i==1){
                throw new RuntimeException("数据库异常");
            }
            rows+=sysUserMapper.insert(sysUser);
        }
        return rows;
    }

    public void setSysUserMapper(SysUserMapper sysUserMapper){
        this.sysUserMapper = sysUserMapper;
    }
}
